<template>
<el-card shadow="never">
  <div slot="header" >
    <span class="card-head-title">附件信息</span>
    <el-button style="float: right" plain>系统验证</el-button>
  </div>
  <el-table
    :data="tableData"
    style="width: 100%">
    <el-table-column
      label="附件">
      <template slot-scope="scope">
        <i class="el-icon-document-remove"></i>
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="文件">
      <template >
        <upload />
      </template>
    </el-table-column>
    <el-table-column label="验证结果">
      <template slot-scope="scope">
        <el-tag type="success" v-if="scope.row.status"><i class="el-icon-success" /><span class="tag-text">系统验证通过</span></el-tag>
        <div v-if="!scope.row.status">
          <el-tag type="danger"><i class="el-icon-warning" /><span class="tag-text">{{scope.row.error}}</span></el-tag>
          <div class="tag-btn">
            <el-popconfirm :title="`是否确认 ${scope.row.name} 无误？`">
              <el-button size="mini" type="danger" plain slot="reference">人工验证</el-button>
            </el-popconfirm>
          </div>
        </div>
      </template>
    </el-table-column>
  </el-table>
</el-card>
</template>

<script>
import Upload from './upload.vue';
export default {
  name: 'AttachmentTag',
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '采购合同',
        status: 1
      }, {
        date: '2016-05-04',
        name: '销售合同',
        status: 1
      }, {
        date: '2016-05-01',
        name: '采购付款银行回单',
        status: 1
      }, {
        date: '2016-05-03',
        name: '物流运输单',
        status: 0,
        error: '物流运输单识别有误'
      }, {
        date: '2016-05-03',
        name: '终端结算单',
        status: 0,
        error: '终端结算单识别有误'
      }, {
        date: '2016-05-03',
        name: '进项发票',
        status: 1
      }]
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  },
  components: {
    Upload
  }
};
</script>
<style lang="scss" scoped>
.card-head-title{
  display: inline-block;
  padding: 8px 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: rgba(0,0,0,.85);
  font-weight: 500;
  font-size: 16px;
}
.tag-text{
  margin-left: 8px;
}
.tag-btn{
  margin-top: 8px;
}
</style>
